function dist(t,i,j,      v1,v2,c,delta,inc,n,w,n1,n2) {
    if (i==j) return 0
    n = 10^-10
    for(c in t["use"]) {
        if (c in t["class"]) continue;
        n1=v1 = t[i][c]
        n2=v2 = t[j][c]
        if ( (v1 != "?") && (v2 != "?") ) {               
            if (c in t["num"]) {
                n1=norm(t,v1,c)
                n2=norm(t,v2,c)
                inc = (n1-n2)^2
            } else {
                inc = (v1 == v2 ? 0 : 1)
            }
            w      = t["weight"][c]
            delta += inc*w
            n     += w
        }}
    return sqrt(delta)/sqrt(n)
}
function norm(t,n,c,    out) {
    return (n - t["min"][c]) / (t["max"][c] - t["min"][c] + 10^-10);
    #out= (n - t["min"][c]) / (t["max"][c] - t["min"][c] + 10^-10);
    #if (ok(out >= 0 && out <= 1, 
    #      out " not 0..1 min " t["min"][c] " max " t["max"][c] " n " n))
    #x  return out
}
